import React, { Component } from 'react'
import { connect } from "react-redux"
import { Link } from "react-router-dom"


 class Three extends Component {

  render() {
    // console.log(this.props.list)
    return (
      <div>
        {
          this.props.list.length==0?<div>暂无数据， <Link to="/">请回到首页添加</Link> </div>:
          this.props.list.map(v=>(
            <div key={v.id}>
              <h1>商品名：{v.name}</h1>
              <h1>价格：{v.price}</h1>
              <h1>数量：{v.num}</h1>
              <hr />
            </div>
          ))

        }
         

      </div>
    )
  }
}

const mapStateToProps=(state)=>{
  return {
      list: state.carList
  }
}

export default connect(
  mapStateToProps
)(Three)